﻿
using Medicine.Entity;
using Medicine.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Medicine.Entity;
namespace Medicine
{
    public partial class Form1 : Form
    {
        private UserService uss=new UserService();
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)//注册接口
        {
            register r = new register();

            this.Hide();
            r.Show();

        }

        private void button1_Click(object sender, EventArgs e)//登录接口
        {

            String num = this.textBox1.Text.Trim();
            String passwd = this.textBox2.Text.Trim();
            User us = new User();
            us.Number = num;
            us.Passwd = passwd;
            uss.check(us);
            //登录失败，账号密码不对
            if (num != "" && passwd != "")
            {
                if (us.Id == -1)
                {
                    MessageBox.Show("账号密码不对，或者没有注册！！！");
                }
                else
                {
                    if (us.Authority == 0)
                    {
                        AdminForm a = new AdminForm(us);

                        this.Hide();
                        a.Show();
                    }
                    else
                    {
                        UserForm u1 = new UserForm(us);

                        this.Hide();
                        u1.Show();


                    }
                }
            }
            else
            {
                MessageBox.Show("没有填完");
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}
